<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <title>天猫搜索1111</title>
    <link rel="stylesheet" th:href="@{/css/style.css}"/>
    <link rel="stylesheet" href="//cdn.staticfile.org/element-ui/2.13.1/theme-chalk/index.css">
</head>
<body class="pg">
<div class="page" id="app">
    <div id="mallPage" class="mallist tmall- page-not-market">
        <div id="header" class=" header-list-app">
            <div class="headerLayout">
                <div class="headerCon">
                    <h1 id="mallLogo">
                        <img src="//img.alicdn.com/tfs/TB11ojWRXXXXXafaFXXXXXXXXXX-190-27.png" alt="我是一只天猫">
                    </h1>
                    <div class="header-extra">
                        <div id="mallSearch" class="mall-search">
                            <form name="searchTop" class="mallSearch-form clearfix">
                                <fieldset>
                                    <legend>天猫搜索</legend>
                                    <div class="mallSearch-input clearfix">
                                        <div class="s-combobox" id="s-combobox-685">
                                            <div class="s-combobox-input-wrap">
                                                <input v-model="keyword" type="text" autocomplete="off" value="" id="mq" class="s-combobox-input" aria-haspopup="true">
                                            </div>
                                        </div>
                                        <button type="submit" @click.prevent="handleCurrentChange(1)" id="searchbtn">
                                            搜索
                                        </button>
                                    </div>
                                </fieldset>
                            </form>
                            <ul class="relKeyTop">
                                <li><a>相关搜索1</a></li>
                                <li><a>相关搜索2</a></li>
                                <li><a>相关搜索3</a></li>
                                <li><a>相关搜索4</a></li>
                                <li><a>相关搜索5</a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div id="content">
            <div class="main">
                <form class="navAttrsForm">
                    <div class="attrs j_NavAttrs" style="display:block">
                        <div class="brandAttr j_nav_brand">
                            <div class="j_Brand attr">
                                <div class="attrKey"> 品牌 </div>
                                <div class="attrValues">
                                    <ul class="av-collapse row-2">
                                        <li><a href="http://www.javadaily.cn" target="_blank"> 淘宝 </a></li>
                                        <li><a href="http://www.javadaily.cn" target="_blank"> 天猫 </a></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>

                <div class="filter clearfix">
                    <a class="fSort fSort-cur">综合<i class="f-ico-arrow-d"></i></a>
                    <a class="fSort">人气<i class="f-ico-arrow-d"></i></a>
                    <a class="fSort">新品<i class="f-ico-arrow-d"></i></a>
                    <a class="fSort fSort-cur" @click="searchSort('sales')">销量<i class="f-ico-arrow-d"></i></a>
                    <a class="fSort" @click="searchSort('price')">价格<i class="f-ico-triangle-mt"></i><i class="f-ico-triangle-mb"></i></a>
                </div>

                <div class="view grid-nosku">
                    <div class="product" v-for="result in results">
                        <div class="product-iWrap">
                            <div class="productImg-wrap">
                                <a class="productImg" :href="result.tbkLink" target="_blank">
                                    <img :src="result.masterPic">
                                </a>
                            </div>
                            <p class="productPrice">
                                <em>{{result.itemPrice}}</em>
                            </p>
                            <p class="productTitle">
                                <a :title="result.itemName" v-html="result.itemNameHighlight" :href="result.tbkLink" target="_blank"></a>
                            </p>
                            <div class="productShop">
                                <span>店铺： {{result.shopName}}</span>
                            </div>
                            <p class="productStatus">
                                <span>月成交<em>{{result.monthlySales}}笔</em></span>
                                <span>评价 <a>9</a></span>
                            </p>
                        </div>
                    </div>
                </div>
                <div style="text-align: center;">
                    <el-pagination @current-change="handleCurrentChange" :current-page="currentPage" :page-size="10" layout="total, prev, pager, next, jumper" :total="total">
                    </el-pagination>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="//cdn.staticfile.org/vue/2.6.11/vue.min.js"></script>
<script src="//cdn.staticfile.org/axios/0.19.2/axios.min.js"></script>
<script src="//cdn.staticfile.org/element-ui/2.13.1/index.js"></script>
<script>
    new Vue({
        el: '#app',
        data: {
            keyword: '',sortType: '',results: [],total: 0,currentPage: 1
        },
        methods: {
            handleCurrentChange: function (val) {
                this.currentPage = val;
                var postData = {'pageNo': this.currentPage,'pageSize': 10,'keyword':this.keyword,'sort':this.sortType};

                axios.post("/search", postData).then(response => {
                    this.results = response.data.data.records;
                    this.total = response.data.data.total;
                });
            },
            searchSort(sort) {
                if (sort == 'price') {
                    if (this.sortType == 'itemPriceDown' || this.sortType == '') {
                        this.sortType = 'itemPriceUp';
                    } else {
                        this.sortType = 'itemPriceDown';
                    }
                }
                if (sort == 'sales') {
                    if (this.sortType == 'monthlySalesDown' || this.sortType == '') {
                        this.sortType = 'monthlySalesUp';
                    } else {
                        this.sortType = 'monthlySalesDown';
                    }
                }
                this.handleCurrentChange(1);
            }
        },
        mounted() {
            this.keyword = '手机';
            this.handleCurrentChange(1);
        }
    });
</script>

</body>
</html>